﻿/*
 * Copyright (c) 2000-2015 Tacke Consulting, Inc
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
 * documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
 * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 
 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions 
 * of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
 * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
 * DEALINGS IN THE SOFTWARE.
 * 
 */
using System;

using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace OpenNETCF.Media.DirectShow
{
    /// <summary>
    /// The IMediaEvent interface contains methods for retrieving event notifications and for overriding 
    /// the Filter Graph Manager's default handling of events.
    /// </summary>
    [ComImport]
    [Guid("56A868B6-0AD4-11CE-B03A-0020AF0BA770")]
    [InterfaceType(ComInterfaceType.InterfaceIsDual)]
    internal interface IMediaEvent
    {
        /// <summary>
        /// The GetEventHandle method retrieves a handle to a manual-reset event that remains signaled while 
        /// the queue contains event notifications.
        /// </summary>
        /// <returns>Handle for the event.</returns>
        IntPtr GetEventHandle();

        /// <summary>This method retrieves the next notification event.</summary>
        /// <param name="lEventCode">Next event notification.</param>
        /// <param name="lParam1">First parameter of the event.</param>
        /// <param name="lParam2">Second parameter of the event.</param>
        /// <param name="msTimeout">Time, in milliseconds, to wait before assuming that there are no events.</param>
        void GetEvent([Out] out uint lEventCode, [Out] out uint lParam1, [Out] out uint lParam2, [In] uint msTimeout);

        /// <summary>This method blocks execution of the application thread until the graph's operation finishes.</summary>
        /// <param name="msTimeout">Duration of the time-out, in milliseconds. Pass zero to return immediately.</param>
        /// <param name="pEvCode">Event that terminated the wait.</param>
        /// <returns>HRESULT</returns>
        [PreserveSig]
        int WaitForCompletion([In] int msTimeout, [Out] out EventCode pEvCode);

        /// <summary>
        /// This method cancels any default handling by the filter graph of the specified 
        /// event and ensures that it is passed to the application.
        /// </summary>
        /// <param name="lEvCode">Event code for which to cancel default handling.</param>
        void CancelDefaultHandling([In] uint lEvCode);

        /// <summary>This method reinstates the normal default handling by a filter graph for the specified event, if there is one.</summary>
        /// <param name="lEvCode">Event to restore.</param>
        void RestoreDefaultHandling([In] uint lEvCode);

        /// <summary>This method frees resources associated with the parameters of an event.</summary>
        /// <param name="lEvCode">Next event notification.</param>
        /// <param name="lParam1">First parameter of the event.</param>
        /// <param name="lParam2">Second parameter of the event.</param>
        void FreeEventParams([In] uint lEvCode, [In] uint lParam1, [In] uint lParam2);
    }
}
